<template>
	<view class="items">
		<view class="title">
			<view class="item_icon">
				<u-icon :name="tool_item.items[selected].icon" color="#007aff"></u-icon>
			</view>
			<text class="texts">{{tool_item.title}}：</text>
		</view>
		<view class="icon_list">
			<view @click="select_sort_type(index)" v-for="(item,index) in tool_item.items" :key="index" class="icon_items">
				<text
				style="margin-inline: 10rpx;"
				:style="{
					'color':selected==index?'#007aff':'#434343'
				}"
				>
					{{item.name}}
				</text>
				<u-icon  
					:color="selected==index?'#007aff':'#398ade'" :size="40" :name="item.icon"  />
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "ToolItemComponent",
		data() {
			return {
				selected:0
			};
		},
		methods: {
			select_sort_type(index) {
				this.selected = index
			}
		},
		props:{
			tool_item:{
				type:Object,
				required:true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.items {
		// border: #007aff dashed 2rpx;
		margin: 0 0 10rpx 0;
		display: flex;
		padding: 4rpx 2rpx;
		align-items: center;
		justify-content: flex-start;
		height: 18%;

		.title {
			height: 50rpx;
			box-sizing: border-box;
			display: flex;
			background-color: #007aff;
			
			border-radius: 20rpx 0 0 20rpx;
			color: #fff;
			padding: 3rpx 10rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			
			.texts{
				font-size: 12px;
				white-space: nowrap;
			}

			.item_icon {
				background-color: #fff;
				border-radius: 50%;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-right: 10rpx;
				padding: 3rpx;
			}
		}

		.icon_list {
			height: 50rpx;
			display: flex;
			border: #007aff solid 1rpx;
			padding: 4rpx;
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: flex-start;
			box-sizing: border-box;
			border-radius: 0 20rpx 20rpx 0;
			overflow-x: scroll;

			.icon_items {
				display: flex;
				font-size: 12px;
				align-items: center;
				justify-content: center;
				background-color: #d5efff;
				padding:5rpx 5rpx;
				height: 80%;
				border-radius: 10rpx;
				white-space: nowrap;
				
				margin-right: 15rpx;
			}
		}
	}
</style>